package com.downloading.bezoyaapp.support.list;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.downloading.bezoyaapp.R;

public class CustomAdapter extends BaseAdapter {

	private ArrayList _data;
	Context _c;

	public CustomAdapter(ArrayList data, Context c) {
		_data = data;
		_c = c;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return _data.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return _data.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) _c
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.embarazo_list_item, null);
		}

		ImageView image = (ImageView) v.findViewById(R.id.embarazo_background);
		TextView textView = (TextView) v.findViewById(R.id.embarazo_text);


		ListData msg = (ListData) _data.get(position);
		
		image.setImageResource(msg.getBackground());
		textView.setText(msg.text);

		return v;
	}

}
